# coding: utf-8
# author: errorcpp@qq.com
# dpkg -L python3-dev
# find /usr/lib /usr/lib/x86_64-linux-gnu -name "libpython3.*"

MESSAGE("---: finding xpython3dev")

find_path(XPYTHON3DEV_INC_DIR Python.h
    HINTS  # 额外搜索路径
    ${_CUSTOM_PYTHON3DEV_BASE_DIR}
    $ENV{INCLUDE}  # VS编译器的include路径变量
    PATH_SUFFIXES include  # 额外的附加子目录
    PATHS
    /usr /usr/local /usr/include /usr/local/include /usr/include/python3.10/
)
MESSAGE("---: XPYTHON3DEV_INC_DIR " ${XPYTHON3DEV_INC_DIR}) 

find_library(XPYTHON3DEV_LIBS
    NAMES libpython3.10.so
    HINTS
    ${_CUSTOM_PYTHON3DEV_BASE_DIR}
    $ENV{LIB}  # VS编译器的include路径变量
    PATH_SUFFIXES lib lib64 lib/x86_64-linux-gnu
    PATHS
    /usr /usr/local /usr/lib /usr/lib64 /usr/local/lib
)

# 检查是否找到Python3开发库
if(XPYTHON3DEV_INC_DIR AND XPYTHON3DEV_LIBS)
    set(XPYTHON3DEV_FOUND TRUE)
    MESSAGE("---: found xpython3dev: XPYTHON3DEV_FOUND=" ${XPYTHON3DEV_FOUND})
    MESSAGE("---: found xpython3dev: XPYTHON3DEV_INC_DIR=" ${XPYTHON3DEV_INC_DIR})
    MESSAGE("---: found xpython3dev: XPYTHON3DEV_LIBS=" ${XPYTHON3DEV_LIBS})
else()
    set(XPYTHON3DEV_FOUND FALSE)
    MESSAGE("---: faild to find xpython3dev")
endif()

# 导出变量
if(XPYTHON3_DEV_FOUND)
  mark_as_advanced(XPYTHON3DEV_INC_DIR XPYTHON3DEV_LIBS XPYTHON3DEV_FOUND)
endif()